package ma.co.ba.BusinessApplications.presentation.components;

import java.beans.PropertyEditorSupport;

import ma.co.ba.BusinessApplications.business.groupes.GroupeBusiness;
import ma.co.ba.BusinessApplications.model.Groupe;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GroupeEditor extends PropertyEditorSupport{

	@Autowired
    GroupeBusiness groupeBusiness;

    // Converts a String to a Groupe (when submitting form)
    
	@Override
    public void setAsText(String text) {
        //Country c = this.countryService.findById(Long.valueOf(text));
        Groupe grp = this.groupeBusiness.getGroupeById(Integer.valueOf(text));
        this.setValue(grp);
    }
	
}
